<template>
  <el-container class="wrapper">
    <el-aside width="200px">
      <div class="logo">
       头条
      </div>
       <el-col>
        <el-menu
          background-color=" rgb(7, 23, 44)"
          text-color="#fff"
          active-text-color="#fff">
            <el-menu-item index="2" @click="jump('/postList')">
              <i class="el-icon-menu"></i>
              <span slot="title">文章列表</span>
            </el-menu-item>
            <el-menu-item index="3" @click="jump('/editPost')">
              <i class="el-icon-document"></i>
              <span slot="title">发布文章</span>
            </el-menu-item> 
          </el-menu>
       </el-col>
    </el-aside>
    <el-container>
        <el-header>
           <img class="avatar" v-if="user.head_img" :src="$axios.defaults.baseURL + user.head_img" alt="">
           <img class="avatar" v-else src="../assets/logo.png" alt="">
           <span class="nickname">{{user.nickname}}</span>
        </el-header>
        <el-main>
          <breadcrumb/>
          <router-view></router-view>
        </el-main>
    </el-container>
  </el-container>
</template>

<script>
import breadcrumb from '../components/breadcrumb'
export default {
  components:{
    breadcrumb
  },
  data(){
    return {
      user:JSON.parse(localStorage.getItem('user'))
    }
  },
  methods:{
    jump(path) {
      if(path!=this.$route.path){
        this.$router.push(path);
      }else{
        return
      }
    }
  }
}
</script>

<style lang="less" scoped>
  .wrapper{
    width: 100%;
    position: absolute;
    top: 0;
    bottom: 0;
  }
  .el-header, .el-footer {
    background-color: rgb(7, 32, 63);
    color: #fff;
    text-align: center;
    line-height: 60px;
  }
  .el-header{
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 90px;
    .avatar {
        width: 48px;
        height: 48px;
        object-fit: cover;
        border-radius: 50%;
        margin-right: 10px;
    }
    .nickname {
        font-weight: bold;
    }
  }
  .el-aside {
    // position: absolute;
    background-color: rgb(7, 23, 44);
    color: #fff;
    text-align: center;
    line-height: 200px;
    .logo{
      position: relative;
      top:30px;
      left: 0;
      height: 40px;
      font-size: 26px;
      font-weight: 600;
      color:  rgb(165, 162, 162);
      // border-radius: 50%;
      // background-color: rgb(165, 162, 162)
    }
    .el-menu{
      position: relative;
      top:130px;
      left: 0;
    }
  }
  
  .el-main {
    background-color: #E9EEF3;
    color: #333;
  }
  
  body > .el-container {
    margin-bottom: 40px;
  }
  
  .el-container:nth-child(5) .el-aside,
  .el-container:nth-child(6) .el-aside {
    line-height: 260px;
  }
  
  .el-container:nth-child(7) .el-aside {
    line-height: 320px;
  }
</style>